package cn.org.eshow.webapp.action.h5;

import cn.org.eshow.bean.query.BlogQuery;
import cn.org.eshow.model.Blog;
import cn.org.eshow.service.BlogManager;
import cn.org.eshow.webapp.action.BaseAction;
import org.apache.struts2.convention.annotation.AllowedMethods;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 资讯H5接口类
 */
@Results({@Result(name = "input", location = "add"),
        @Result(name = "list", type = "redirect", location = ""),
        @Result(name = "success", type = "redirect", location = "view/${id}"),
        @Result(name = "redirect", type = "redirect", location = "${redirect}")})
@AllowedMethods({"view"})
public class BlogAction extends BaseAction {

    @Autowired
    private BlogManager blogManager;

    private List<Blog> blogs;
    private BlogQuery query = new BlogQuery();
    private Blog blog = new Blog();

    public String view() {
        blog = blogManager.get(id);
        if (blog != null) {
            blogManager.updateCount(blog);
        }
        return NONE;
    }

    public List<Blog> getBlogs() {
        return blogs;
    }

    public void setBlogs(List<Blog> blogs) {
        this.blogs = blogs;
    }

    public BlogQuery getQuery() {
        return query;
    }

    public void setQuery(BlogQuery query) {
        this.query = query;
    }

    public Blog getBlog() {
        return blog;
    }

    public void setBlog(Blog blog) {
        this.blog = blog;
    }
}
